package com.ciei.dpagm.controller;

import com.alibaba.fastjson.JSONObject;
import com.ciei.dpagm.common.controller.BaseController;
import com.ciei.dpagm.service.FormPropertyDefinitionService;
import com.ciei.dpagm.util.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author wangyan
 * @date 2022/06/02
 */
@RestController
@RequestMapping("formPropertyDefinition")
public class FormPropertyDefinitionController extends BaseController {

    @Autowired
    private FormPropertyDefinitionService formPropertyDefinitionService;

    @RequestMapping("getFormPropertyDefinitionPageList")
    public JSONObject getFormLayoutPageList(@RequestBody JSONObject page) {
        PageParam pageParam=getPageParams(page);
        return formPropertyDefinitionService.getFormPropertyDefinitionPageList(pageParam);
    }

    @RequestMapping("getFormPropertyDefinitionList")
    public JSONObject getFormPropertyDefinitionList(@RequestBody JSONObject query) {
        return formPropertyDefinitionService.getFormPropertyDefinitionList(query.getInteger("businessModule"),query.getInteger("componentType"));
    }

    /**
     * 表单字段管理-新增
     */
    @RequestMapping("addFormPropertyDefinition")
    public JSONObject addFormPropertyDefinition(@RequestBody JSONObject data) {
        return formPropertyDefinitionService.addFormPropertyDefinition(data);
    }

    /**
     * 表单字段管理-编辑
     */
    @RequestMapping("editFormPropertyDefinition")
    public JSONObject editFormPropertyDefinition(@RequestBody JSONObject data) {
        return formPropertyDefinitionService.editFormPropertyDefinition(data);
    }

    /**
     * 表单字段管理-删除
     */
    @RequestMapping("deleteFormPropertyDefinition")
    public JSONObject deleteFormPropertyDefinition(@RequestBody JSONObject data) {
        return formPropertyDefinitionService.deleteFormPropertyDefinition(data.getInteger("propertyDefinitionId"));
    }

}
